package top.itpath.common.util;

import cn.hutool.crypto.SmUtil;

/**
 * @author zhaomengru
 * create by  2023/10/10 - 16:42
 * 密码工具
 */
public class PasswordUtil {

    public static String encrypt(String password, String salt) {
        String encryptPassword = SmUtil.sm3(password + salt);
        for (int i = 0; i < 10; i++) {
            encryptPassword = SmUtil.sm3(encryptPassword + salt);
        }
        return encryptPassword;
    }

    public static boolean verify(String password, String salt, String encryptPassword) {
        return encrypt(password, salt).equals(encryptPassword);
    }
}
